@push('title')
    <title>OTA权限分配</title>
@endpush
@extends('layout.layer')
@section('content')
    <form class="layui-form layui-form-pane1" action="#" lay-filter="first">
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <input type="hidden" name="admin_id_platform" value="{{$admin['id']}}">

        <div class="layui-form-item">
            <label class="layui-form-label">管理员</label>
            <div class="layui-input-inline">
                <input type="text" name="name" value="{{$admin['nickname']}}" disabled placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">OTA授权</label>
            <div class="layui-input-block">
                <input type="checkbox" name="platform[]" value="10" title="恒博携程" @if(in_array(10,$platform)) checked @endif>&nbsp;
                <input type="checkbox" name="platform[]" value="11" title="茂华携程" @if(in_array(11,$platform)) checked @endif>&nbsp;
                <input type="checkbox" name="platform[]" value="20" title="携程规则运价" @if(in_array(20,$platform)) checked @endif>&nbsp;
                <input type="checkbox" name="platform[]" value="21" title="茂华规则运价" @if(in_array(21,$platform)) checked @endif>&nbsp;
                <input type="checkbox" name="platform[]" value="30" title="去哪" @if(in_array(30,$platform)) checked @endif>&nbsp;
                <input type="checkbox" name="platform[]" value="40" title="同城" @if(in_array(40,$platform)) checked @endif>&nbsp;
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
@endsection
@push('script')
    <script>
        layui.use(['form','layer'], function() {

            var $ = layui.$
                , form = layui.form
                , layer = layui.layer;

            //监听提交
            form.on('submit(*)', function(data){


                $.ajax({
                    url: '/adminplatform/ajaxAdd'
                    , method: 'post'
                    , data: data.field
                    , dataType: 'json'
                    , success: function (data) {

                        layer.msg(data.errmsg, {
                            offset: '25px'
                            ,icon: (data.errcode === 0 ? 1: 5)
                            ,time: 25000
                            ,area:['400px','66px']
                        }, function(){});

                        if (data.errcode === 0) {

                            //$('#alert-form')[0].reset();
                        }

                        // layer.close(loading);
                    },
                });

                return false;
            });

        });
    </script>
@endpush
